//
//  UIView+AdminView.m
//  CarHome
//
//  Created by 莫晓芳 on 15-5-9.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "UIView+AdminView.h"

@implementation UIView (AdminView)

- (void)addMyActivityIndicatorView {
    CGRect rect = self.frame;
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, rect.size.width, rect.size.height)];
    view.backgroundColor = [UIColor whiteColor];
    view.tag = 88;
    
    UIImageView *bottomView = [[[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 100, 100)] autorelease];
    bottomView.center = CGPointMake(rect.size.width / 2, rect.size.height / 2);
    bottomView.image = [UIImage imageNamed:@"loadingpage_bg"];
    [view addSubview:bottomView];
    
    UIImageView *rotationView = [[[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 100, 100)] autorelease];
    rotationView.center = CGPointMake(rect.size.width / 2, rect.size.height / 2);
    rotationView.image = [UIImage imageNamed:@"load_icon"];
    
    CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI_2];
    rotationAnimation.duration = .5;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = 10000;
    [rotationView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
    [view addSubview:rotationView];
    [self addSubview:view];
}

- (void)addMyActivityIndicatorView2 {
    CGRect rect = self.frame;
    UIView *view = [[UIView alloc] initWithFrame:rect];
    view.tag = 88;
    
    UIImageView *bottomView = [[[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 100, 100)] autorelease];
    bottomView.center = CGPointMake(rect.size.width / 2, rect.size.height / 2 - 100);
    bottomView.image = [UIImage imageNamed:@"loadingpage_bg"];
    [view addSubview:bottomView];
    
    UIImageView *rotationView = [[[UIImageView alloc] initWithFrame:CGRectMake(20, 20, 100, 100)] autorelease];
    rotationView.center = CGPointMake(rect.size.width / 2, rect.size.height / 2 - 100);
    rotationView.image = [UIImage imageNamed:@"load_icon"];
    
    CABasicAnimation *rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI_2];
    rotationAnimation.duration = .5;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = 10000;
    [rotationView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
    [view addSubview:rotationView];
    [self addSubview:view];
}

- (void)removeMyActivityIndicatorViewFromSuperView {
    UIView *myView = [self viewWithTag:88];
    [myView removeFromSuperview];
    [myView release];
}


@end
